#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "../camion/camion.c"


#define MAX 10

struct point
{
  char *name;
  unsigned int x;
  unsigned int y;
};

typedef struct point point;


int write_in_file(char name[], camion *C)
{
  FILE *f;
  
  f = fopen(name,"wb");
  
  if( f == NULL)
    return -1;

  fwrite(C, sizeof(point), 1, f);
  //fprintf(f, "%s\n%d\n%d\n", P->name, P->x, P->y);
  //fputs(P->name,f);

  fclose(f);
  return 1;
}


camion* read_in_file(char name[])
{
  FILE *f;
  camion *C;

  f = fopen(name,"rb");

  fread(C, sizeof(point), 1 , f);

  fclose(f);
  return C;
}



int main()
{
  camion *C1, *C2;
  

  C1 = empty_camion();
  
  C1->capacity = 10.2;
  add_event_to_camion(C1, new_event(new_date(2,1,2014,12,0),new_date(2,1,2014,12,30), new_client("Auchan",1), 3.5));



  // write_in_file("essai.bin", P2);
  write_in_file("C1.bin", C1);

  C2 = read_in_file("C1.bin");


  print_fifo(C2->calendar[0][1][2]);

  return 0;
}
